package com.joeyzh.utils;

import com.joey.base.util.SharedPreferenceUtils;
import com.joeyzh.iframe.db.entity.UserEntity;
import com.joeyzh.iframe.db.utils.DbUserManager;

/**
 * Created by Joey on 2018/5/25.
 */

public class Caches {

    private static UserEntity user;
    private static String moduleTag;

    public static UserEntity getUser() {
        if (user == null) {
            String userId = SharedPreferenceUtils.getInstance().getString("username");
            user = new DbUserManager().queryById(userId);
        }
        if (user == null) {
            user = new UserEntity();
            user.setUserName("用信息获取失败");
            user.setUserId("用户Id获取失败");
        }
        return user;
    }

    public static void setUser(UserEntity user) {
        Caches.user = user;
    }

    public static void setModule(String tag) {
        moduleTag = tag;
    }

    public static String getModuleTag() {
        return moduleTag;
    }
}
